package com.jettech.oa.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.annotations.Type;
/**
 * 流程实例
 * @author Administrator
 *
 */
@Entity
@Table(name="jettech_work_flow")
public class WorkFlow implements Serializable {
	private static final long serialVersionUID = -4471023095122417421L;
	private Long id;//主键
	private User user;//创建者
	private String name;//流程名称 这里的名称是流程定义processDefinedFile里面 process-definition 中的name属性对应的值
	private byte[] processDefinedFile;//流程的定义名称
	private byte[] processDefinedImage;//流程的图片
	private List<WorkFlowForm> forms;
	private String status;//状态
	private String desc;//描述
	private Date createdTime;//创建时间
	private Date updatedTime;//更新时间
	
	public WorkFlow(){
		
	}

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="work_flow_id")
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="user_id")
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	@Column(name="work_flow_name",nullable=false)
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Type(type="binary")
	@Column(name="process_defined_image",length=9999999)
	public byte[] getProcessDefinedImage() {
		return processDefinedImage;
	}
	public void setProcessDefinedImage(byte[] processDefinedImage) {
		this.processDefinedImage = processDefinedImage;
	}
	@Type(type="binary")
	@Column(name="process_defined_file",length=9999999)
	public byte[] getProcessDefinedFile() {
		return processDefinedFile;
	}
	public void setProcessDefinedFile(byte[] processDefinedFile) {
		this.processDefinedFile = processDefinedFile;
	}
	@OneToMany(targetEntity=WorkFlowForm.class,fetch=FetchType.LAZY,mappedBy="workFlow")
	public List<WorkFlowForm> getForms() {
		return forms;
	}
	public void setForms(List<WorkFlowForm> forms) {
		this.forms = forms;
	}
	@Column(name="work_flow_status",length=8)
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	@Column(name="work_flow_desc")
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	@Column(name="created_time",updatable=false)
	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreatedTime() {
		return createdTime;
	}
	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}
	@Column(name="updateed_time")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getUpdatedTime() {
		return updatedTime;
	}
	public void setUpdatedTime(Date updatedTime) {
		this.updatedTime = updatedTime;
	}

	public boolean equals(Object other){
		return EqualsBuilder.reflectionEquals(this, other);
	}
	public int hashCode(){
		return HashCodeBuilder.reflectionHashCode(this);
	}
	public String toString(){
		return ToStringBuilder.reflectionToString(this);
	}
}
